<html><!-- Created using the cpp_pretty_printer from the dlib C++ library.  See http://dlib.net for updates. --><head><title>dlib C++ Library - thread_function_extension_abstract.h</title></head><body bgcolor='white'><pre>
<font color='#009900'>// Copyright (C) 2007  Davis E. King (davis@dlib.net)
</font><font color='#009900'>// License: Boost Software License   See LICENSE.txt for the full license.
</font><font color='#0000FF'>#undef</font> DLIB_THREAD_FUNCTIOn_ABSTRACT_
<font color='#0000FF'>#ifdef</font> DLIB_THREAD_FUNCTIOn_ABSTRACT_ 

<font color='#0000FF'>#include</font> "<a style='text-decoration:none' href='threads_kernel_abstract.h.html'>threads_kernel_abstract.h</a>"

<font color='#0000FF'>namespace</font> dlib
<b>{</b>

<font color='#009900'>// ----------------------------------------------------------------------------------------
</font>
    <font color='#0000FF'>class</font> <b><a name='thread_function'></a>thread_function</b> 
    <b>{</b>
        <font color='#009900'>/*!
            WHAT THIS OBJECT REPRESENTS
                This object represents a thread on a global C++ function or function
                object.  That is, it allows you to run a function in its own thread.
        !*/</font>
    <font color='#0000FF'>public</font>:

        <font color='#0000FF'>template</font> <font color='#5555FF'>&lt;</font><font color='#0000FF'>typename</font> F<font color='#5555FF'>&gt;</font>
        <b><a name='thread_function'></a>thread_function</b> <font face='Lucida Console'>(</font>
            F funct
        <font face='Lucida Console'>)</font>;
        <font color='#009900'>/*!
            ensures
                - #*this is properly initialized
                - the function funct has been started in its own thread
            throws
                - std::bad_alloc
                - dlib::thread_error
                    the constructor may throw this exception if there is a problem 
                    gathering resources to create threading objects.
        !*/</font>

        <font color='#0000FF'>template</font> <font color='#5555FF'>&lt;</font><font color='#0000FF'>typename</font> F, <font color='#0000FF'>typename</font> T1<font color='#5555FF'>&gt;</font>
        <b><a name='thread_function'></a>thread_function</b> <font face='Lucida Console'>(</font>
            F funct,
            T1 arg1
        <font face='Lucida Console'>)</font>;
        <font color='#009900'>/*!
            ensures
                - #*this is properly initialized
                - A thread has been created and it will call funct(arg1)
            throws
                - std::bad_alloc
                - dlib::thread_error
                    the constructor may throw this exception if there is a problem 
                    gathering resources to create threading objects.
        !*/</font>

        <font color='#0000FF'>template</font> <font color='#5555FF'>&lt;</font><font color='#0000FF'>typename</font> F, <font color='#0000FF'>typename</font> T1, <font color='#0000FF'>typename</font> T2<font color='#5555FF'>&gt;</font>
        <b><a name='thread_function'></a>thread_function</b> <font face='Lucida Console'>(</font>
            F funct,
            T1 arg1,
            T2 arg2
        <font face='Lucida Console'>)</font>;
        <font color='#009900'>/*!
            ensures
                - #*this is properly initialized
                - A thread has been created and it will call funct(arg1, arg2)
            throws
                - std::bad_alloc
                - dlib::thread_error
                    the constructor may throw this exception if there is a problem 
                    gathering resources to create threading objects.
        !*/</font>

        <font color='#0000FF'>template</font> <font color='#5555FF'>&lt;</font><font color='#0000FF'>typename</font> F, <font color='#0000FF'>typename</font> T1, <font color='#0000FF'>typename</font> T2, <font color='#0000FF'>typename</font> T3<font color='#5555FF'>&gt;</font>
        <b><a name='thread_function'></a>thread_function</b> <font face='Lucida Console'>(</font>
            F funct,
            T1 arg1,
            T2 arg2,
            T3 arg3
        <font face='Lucida Console'>)</font>;
        <font color='#009900'>/*!
            ensures
                - #*this is properly initialized
                - A thread has been created and it will call funct(arg1, arg2, arg3)
            throws
                - std::bad_alloc
                - dlib::thread_error
                    the constructor may throw this exception if there is a problem 
                    gathering resources to create threading objects.
        !*/</font>

        <font color='#0000FF'>template</font> <font color='#5555FF'>&lt;</font><font color='#0000FF'>typename</font> F, <font color='#0000FF'>typename</font> T1, <font color='#0000FF'>typename</font> T2, <font color='#0000FF'>typename</font> T3, <font color='#0000FF'>typename</font> T4<font color='#5555FF'>&gt;</font>
        <b><a name='thread_function'></a>thread_function</b> <font face='Lucida Console'>(</font>
            F funct,
            T1 arg1,
            T2 arg2,
            T3 arg3,
            T4 arg4
        <font face='Lucida Console'>)</font>;
        <font color='#009900'>/*!
            ensures
                - #*this is properly initialized
                - A thread has been created and it will call funct(arg1, arg2, arg3, arg4)
            throws
                - std::bad_alloc
                - dlib::thread_error
                    the constructor may throw this exception if there is a problem 
                    gathering resources to create threading objects.
        !*/</font>

        ~<b><a name='thread_function'></a>thread_function</b> <font face='Lucida Console'>(</font>
        <font face='Lucida Console'>)</font>;
        <font color='#009900'>/*!
            ensures
                - all resources allocated by *this have been freed.  
                - blocks until is_alive() == false
        !*/</font>

        <font color='#0000FF'><u>bool</u></font> <b><a name='is_alive'></a>is_alive</b> <font face='Lucida Console'>(</font>
        <font face='Lucida Console'>)</font> <font color='#0000FF'>const</font>;
        <font color='#009900'>/*!
            ensures
                - if (this object's thread has yet to terminate) then
                    - returns true
                - else
                    - returns false
        !*/</font>

        <font color='#0000FF'><u>void</u></font> <b><a name='wait'></a>wait</b> <font face='Lucida Console'>(</font>
        <font face='Lucida Console'>)</font> <font color='#0000FF'>const</font>;
        <font color='#009900'>/*!
            ensures
                - if (is_alive() == true) then
                    - blocks until this object's thread terminates
        !*/</font>

    <font color='#0000FF'>private</font>:

        <font color='#009900'>// restricted functions
</font>        <b><a name='thread_function'></a>thread_function</b><font face='Lucida Console'>(</font>thread_function<font color='#5555FF'>&amp;</font><font face='Lucida Console'>)</font>;        <font color='#009900'>// copy constructor
</font>        thread_function<font color='#5555FF'>&amp;</font> <b><a name='operator'></a>operator</b><font color='#5555FF'>=</font><font face='Lucida Console'>(</font>thread_function<font color='#5555FF'>&amp;</font><font face='Lucida Console'>)</font>;    <font color='#009900'>// assignment operator
</font>    <b>}</b>;

<font color='#009900'>// ----------------------------------------------------------------------------------------
</font>
<b>}</b>

<font color='#0000FF'>#endif</font> <font color='#009900'>// DLIB_THREAD_FUNCTIOn_ABSTRACT_
</font>


</pre></body></html>